import service from './interceptors';

const fetchData = {
  get(url, params) {
    return new Promise(async (resolve, reject) => {
      try {
        const res = await service({
          method: 'GET',
          url,
          params
        })
        resolve(res)
      } catch (error) {
        reject(error)
      }
    })
  },
  post(url, data, params) {
    return new Promise(async (resolve, reject) => {
      try {
        const res = await service({
          method: 'POST',
          url,
          params,
          data
        })
        resolve(res)
      } catch (error) {
        reject(error)
      }
    })
  },
}

export default fetchData;
